<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'core.crypt.class.php');

//
function func_cc_encrypt($cc_number) {
	$cryptObj = new CoreCrypt();
	$cryptObj->type = 'md5t';
	$cryptObj->ekey = '$PPEMI$';
	
	return $cryptObj->encrypt($cc_number);
}

function func_cc_decrypt($cc_number) {
	$cryptObj = new CoreCrypt();
	$cryptObj->type = 'md5t';
	$cryptObj->ekey = '$PPEMI$';
	
	return $cryptObj->decrypt($cc_number);
}

function func_cc_decrypt_last($cc_number) {
	$cc_number = func_cc_decrypt($cc_number);
	
	return substr($cc_number, -4);
}

function func_cc_decrypt_last_x($cc_number) {
	$cc_number = func_cc_decrypt($cc_number);
	
	return 'XXX-' . substr($cc_number, -4);
}
//
?>